<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:o="http://openfaces.org/"
	xmlns:s="http://jboss.com/products/seam/taglib"
	template="/WEB-INF/esquema/permitTemplate.xhtml">


	<ui:define name="mainControls">
		<h:outputText value="Opciones" />
		<h:outputText value="     " />
		<h:panelGroup>
			<o:commandButton value="&lt;&lt; #{messages['txt.back']}" onclick="goBack();"/>
			<o:commandButton rendered="#{buildingPermitHelper.spatialAnalysisOK}" value="#{messages['button.next']} &gt;&gt;" onclick="goNext();"/>
		</h:panelGroup>
	</ui:define>

	<ui:define name="title">
		<div align="center">
			<br/>
			<strong>#{messages['building_permit.start_header']}</strong>
			<rich:separator lineType="solid"/>
			<br/>
		</div>
	</ui:define>
	
	<ui:define name="permitBody">
		<h:form>
			<style type="text/css">
				.introCol1 {
					vertical-align:top;
					width:30%;
				}
				.introCol2 {
					vertical-align:top;
					width:70%;
				}
			</style>
			
			
			<div align="center">
				<table style="text-align:center;margin:auto;" cellspacing="10">
					<tr>
						<th style="text-align: left;">#{messages['permit.spatial_rulegroup_to_apply']}</th>
						<td style="text-align: left;">
							<h:outputText value="#{generalHelper.formatRuleGroupText( buildingPermitHelper.permit.ruleGroup )}" />
							
							<ui:remove>
							<h:selectOneMenu value="#{buildingPermitHelper.ruleGroup}" converter="#{buildingPermitHelper.permitRuleGroupConverter}" style="width: 95%">
								<f:selectItems value="#{buildingPermitHelper.permitRuleGroupItemList}"/>
							</h:selectOneMenu>
							</ui:remove>
						</td>
					</tr>
				</table>
				
				<ui:remove>
				<h:form>
					<table style="text-align:center;width:90%;margin:auto;">
						<tr>
							<th style="text-align: left;width: 40%">#{messages['permit.spatial_rulegroup_to_apply']}</th>
							<td>
								<h:selectOneMenu value="#{buildingPermitHelper.ruleGroup}" converter="#{buildingPermitHelper.permitRuleGroupConverter}" style="width: 95%">
									<f:selectItems value="#{buildingPermitHelper.permitRuleGroupItemList}"/>
								</h:selectOneMenu>
							</td>
						</tr>
						<tr>
							<td style="text-align: center" colspan="2">
								<br />
								<a4j:commandButton
									value="Realizar analisis"
									action="#{spatialAnalysisHelper.doNewSpatialAnalysis}"
									reRender="#{spatialAnalysisHelper.spatialAnalysisPanelName}">
									<f:setPropertyActionListener target="#{spatialAnalysisHelper.spatialZone}" value="#{buildingPermitHelper.permit.selectedZone}" />
									<f:setPropertyActionListener target="#{spatialAnalysisHelper.ruleGroup}" value="#{buildingPermitHelper.ruleGroup}" />
									<f:setPropertyActionListener target="#{spatialAnalysisHelper.distance}" value="#{null}" />
								</a4j:commandButton>
							</td>
						</tr>
					</table>
				</h:form>
				</ui:remove>
				
				<br />
				<h:panelGroup id="spatialAnalysisResPanel">
					<h:panelGroup rendered="#{not buildingPermitHelper.spatialAnalysisOK}">
						<h:graphicImage value="/img/wrong-icon.png" />
						<br />
						<h:outputText value="Se encontraron las siguientes restricciones" />
						<br />
						<br />
						<table>
							<tr>
								<td>
									<ul>
										<ui:repeat var="sr" value="#{buildingPermitHelper.restrictingRuleList}">
											<li>#{generalHelper.spatialRuleText(sr, true)}</li>
										</ui:repeat>
									</ul>
								</td>
							</tr>
						</table>
					</h:panelGroup>
					<h:panelGroup rendered="#{buildingPermitHelper.spatialAnalysisOK}">
						<h:graphicImage value="/img/right-icon.png" />
						<br />
						<h:outputText value="No se encontraron restricciones" />
					</h:panelGroup>
				</h:panelGroup>
				<br />
				<br />
				<br />
				
				<ui:include src="/permits/includes/spatialAnalysisIncl.xhtml"/>
			</div>
			
			<br />
			<a4j:jsFunction
				name="goBack"
				action="#{buildingPermitHelper.goBack}">
			</a4j:jsFunction>
			<a4j:jsFunction
				name="goNext"
				action="next">
			</a4j:jsFunction>
		</h:form>
	</ui:define>



<ui:remove>
<h:form xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

	<style type="text/css">
		.col {
			vertical-align:top;
		}
	</style>

	<ui:include src="/WEB-INF/includes/showHelpIncl.xhtml">
		<ui:param name="width" value="500" />
		<ui:param name="mainMessage" value="#{messages['building_permit.requestcompleted']}" />
		<ui:param name="observation" value="#{messages['introfin.observation']}:" />
		
		<ui:param name="msgBullet" value="#{messages['introfin.observation1']}" />
		<ui:param name="msgBullet1" value="#{messages['introfin.observation2']}" />
		<ui:param name="msgBullet2" value="#{messages['building_permit.observation']}" />
	</ui:include>

	<div align="center">
		<br/>
		<strong>#{messages['introfin.transactiondata']}</strong>
	</div>
	<rich:separator lineType="solid"/>
	<h:panelGrid columns="2" columnClasses="col,col">
		<h:outputText value="#{messages['permit.partyid']}:"/>
		<h:outputText value="#{buildingPermitHelper.partyNationalIdentity}"/>

		<h:outputText value="#{messages['permit.party_full_name']}:"/>
		<h:outputText value="#{buildingPermitHelper.partyName}"/>
		
		<h:outputText value="#{messages['permit.validity_from']}" />
		<h:outputText value="#{buildingPermitHelper.permit.validityFrom}" />

		<h:outputText value="#{messages['permit.validity_to']}" />
		<h:outputText value="#{buildingPermitHelper.permit.validityTo}" />

		<h:outputText value="#{messages['permit.request_text']}:"/>
		<h:inputTextarea value="#{buildingPermitHelper.permit.requestText}" readonly="true" rows="5" cols="30"/>
	</h:panelGrid>
	
	<br/>

	<div align="center">
		<strong>#{messages['introfin.attacheddocs']}</strong>
	</div>
	<rich:separator lineType="solid"/>

	<h:panelGroup id="tabla">
		<h:outputText value="#{messages['introfin.nofilesattached']}" rendered="#{empty buildingPermitHelper.attachedFiles}"/>
		<br />
		<rich:dataTable value="#{buildingPermitHelper.attachedFiles}"
				var="file" rowKeyVar="row" align="center"
				rendered="#{not empty buildingPermitHelper.attachedFiles}">
			<rich:column>
				<f:facet name="header">#{messages['introfin.filename']}</f:facet>
				<h:outputText value="#{file.fileName}"/>
			</rich:column>
	
			<rich:column>
				<f:facet name="header">#{messages['intro2.description']}</f:facet>
				<h:outputText value="#{file.descripcion}"/>
			</rich:column>
		</rich:dataTable>
	</h:panelGroup>

	<br />
	<br />
	<br />

	<a4j:commandButton value="#{messages['BACK']}" action="#{buildingPermitHelper.hasAttachedFiles}"/>
	<h:outputText value="   "/>
	<a4j:commandButton value="#{messages['FINISH']}" action="#{buildingPermitHelper.beginProcess}"/>
</h:form>
</ui:remove>

</ui:composition>
